<!doctype html>
<html lang="en">
   <head>
		<title>Clusterer with Bing maps and jQuery - Bing maps jQuery plugin</title>
		<meta charset="utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta http-equiv="content-language" content="en" />
		<meta name="author" content="Johan Säll Larsson" />
		<meta name="viewport" content="width=device-width,initial-scale=1" />
		<meta name="keywords" content="Bing maps, jQuery, plugin, clustering" />
		<meta name="description" content="An example how to use clustering, jQuery and Bing maps v3 with Bing maps jQuery plugin" />
		<link rel="schema.DC" href="http://purl.org/dc/elements/1.1/" />
		<meta name="DC.title" content="Example with MarkerClusterer, Bing maps and jQuery - Bing maps jQuery plugin" />
		<meta name="DC.subject" content="Bing maps;jQuery;plugin;clustering" />
		<meta name="DC.description" content="An example how to use clustering, jQuery and Bing maps v3 with Bing maps jQuery plugin" />
		<meta name="DC.creator" content="Johan Säll Larsson" />
		<meta name="DC.language" content="en" />
		<link type="text/css" rel="stylesheet" href="css/960/960.css" />
		<link type="text/css" rel="stylesheet" href="css/960/960_16_col.css" />
		<link type="text/css" rel="stylesheet" href="css/normalize/normalize.css" />
		<link type="text/css" rel="stylesheet" href="css/prettify/prettify.css" />
		<link type="text/css" rel="stylesheet" href="css/demo.css" />
		<link type="text/css" rel="stylesheet" href="http://fonts.googleapis.com/css?family=Anton" />
		<script type="text/javascript" src="js/modernizr-2.0.6/modernizr.min.js"></script>
    </head>
    <body>
		<header class="dark">
			<div class="container_16">
				<h1><a href="/">Bing maps jQuery plugin <span id="version"></span></a> clustering example</h1>
			</div>
		</header>
		<div class="container_16">
			<article class="grid_16">
				<div class="item rounded dark">
					<div id="map_canvas" class="map"></div>
				</div>
				<div class="content rounded light shadow">
					<h2>Using jquery with Bing maps</h2>
					<p>
						Download <a href="http://jquery.com/">jQuery 1.4.X or higher</a> or
						use <a href="http://code.google.com/intl/sv-SE/apis/libraries/devguide.html">Googles</a> or <a href="http://www.asp.net/ajaxlibrary/cdn.ashx">Microsofts</a> 
						<abbr title="Content delivery network"><a href="http://en.wikipedia.org/wiki/Content_delivery_network">CDN</a></abbr>.
					</p>
<pre class="prettyprint rounded">
&lt;script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="PATH_TO_PLUGIN/jquery.ui.bmap.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="PATH_TO_PLUGIN/jquery.ui.bmap.extensions.js"&gt;&lt;/script&gt;</pre>

<pre class="prettyprint rounded">
$('#map_canvas').gmap({'credentials': YOUR_BING_MAP_CREDENTIALS}).bind('init', function(ev, map) {
	$.getJSON(YOUR_JSON_URL, function(response) {
		var arrayOfLatLngs = [];
		$.each(response.YOUR_ROOT_NODE, function(i, item) {
			arrayOfLatLngs.push({
				'Latitude': item.latitude,
				'Longitude': item.longitude,
				'Title': item.title,
				'Description': item.description
			});
		});
		$('#map_canvas').gmap('createCluster', arrayOfLatLngs);
	});
});</pre>

<pre class="prettyprint rounded">
$('#map_canvas').gmap({'credentials': YOUR_BING_MAP_CREDENTIALS, 'callback': function() {
	var self = this;
	$.getJSON(YOUR_JSON_URL, function(response) {
		var arrayOfLatLngs = [];
		$.each(response.YOUR_ROOT_NODE, function(i, item) {
			arrayOfLatLngs.push({
				'Latitude': item.latitude,
				'Longitude': item.longitude,
				'Title': item.title,
				'Description': item.description
			});
		});
		self.createCluster(arrayOfLatLngs);
	});
}});</pre>

				</div>
					
			</article>
		</div>
		<footer class="dark">
			<div class="container_16">
				<div class="grid_8">
					<h2>More Bing maps and jQuery examples</h2>
					<ul>
						<li><a href="jquery-bing-maps-hello-world-example.html">Bing maps with jQuery mobile "Hello world" example</a></li>
						<li><a href="jquery-bing-maps-filter-by-property.html">Filter pushpins by property</a></li>
						<li><a href="jquery-bing-maps-load-marker-by-json.html">Load Bing map with JSON data</a></li>
						<li><a href="jquery-bing-maps-geocoding-search.html">Address and longitude/latitude (Geocoding) lookup with Bing maps</a></li>
						<li><a href="jquery-bing-maps-microdata.html">Add markers with microdata</a></li>
						<li><a href="jquery-bing-maps-microformat.html">Add markers with microformats</a></li>
						<li><a href="jquery-bing-maps-rdfa.html">Add markers with RDFa</a></li>
						<li><a href="jquery-bing-maps-extend-with-pagination.html">Extend the plugin with pagination</a></li>
						<li class="sel buttonize"><a href="jquery-google-maps-clustering.html">Using clusters with Bing Maps</a></li>
						<li><a href="jquery-google-maps-data-attribute.html">Add markers with jQuery data attribute</a></li>
						<li><a href="jquery-google-maps-geolocation.html">Bing maps with geolocation</a></li>
						<li><a href="jquery-bing-maps-polygons-and-polylines.html">Polygons and polylines example</a></li>
						<li><a href="jquery-bing-maps-mobile.html">Bing maps with jQuery mobile (jQM)</a></li>
					</ul>
				</div>
				<div id="forum" class="hidden rounded forum grid_8"></div>
				<div class="clear"></div>
				<div itemscope itemtype="http://data-vocabulary.org/Person">
					Author: <span itemprop="name">Johan S&auml;ll Larsson</span> (<a href="http://johansalllarsson.se" itemprop="url">http://johansalllarsson.se</a>)
				</div>
			</div>
		</footer>
		<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
		<script type="text/javascript" src="js/jquery-1.7.1/jquery.min.js"></script>
        <script type="text/javascript" src="js/underscore-1.2.2/underscore-min.js"></script>
		<script type="text/javascript" src="js/backbone-0.5.3/backbone-min.js"></script>
		<script type="text/javascript" src="js/prettify/prettify.min.js"></script>
		<script type="text/javascript" src="js/demo.js"></script>
		<script type="text/javascript" src="../js/jquery.ui.bmap.js"></script>
		<script type="text/javascript" src="../js/jquery.ui.bmap.extensions.js"></script>
		<script type="text/javascript">
            $(function() { 
				demo.add(function() {
					$('#map_canvas').gmap(jQuery.extend({'callback': function() {
						var self = this, objects = [];
						$.getJSON('http://datadotgcds2.cloudapp.net/v1/Hack OpenData/HaltonFluClinics/?format=json&callback=?', function(response) {
							$.each(response.d, function(i, item) {
								objects.push({
									'Latitude': item.latitude,
									'Longitude': item.longitude,
									'Title': item.city,
									'Description': item.address
								});
							});
							self.createCluster(objects);
							self.get('map').setView({'center': new Microsoft.Maps.Location(43.371287,-79.7494506)});
						});
					}}, demo.mapOptions));
				}).load();
			});
        </script>
    
	</body>
</html>